`predict.ruleset` <-
function(ruleset, dataset, names)
{
	# Create a new predict table.
	m <- matrix(nrow=nrow(dataset), ncol=length(names))
	colnames(m) <- names
	table = as.data.frame(m)

	# Get some info.
	c = as.list(names)
	cols = length(c)
	
 	# Apply for each row from dataset.
	for(i in 1:nrow(dataset)) {
		# Clear all.
		for(l in 1:cols) {
			c[[l]][2] = 0
			c[[l]][3] = 0
		}
		summ = 0

		# Evaluate each rule from ruleset.
		for(j in 1:length(ruleset)) {
			if(rule.evaluate(ruleset[[j]],dataset[i,])==TRUE)
			for(l in 1:cols) {
				if(c[[l]][1]==ruleset[[j]]$class) {
					c[[l]][2] = as.numeric(c[[l]][2])+1
				}
			}
		}
		# Calculate prediction for each class
		
		for(l in 1:cols) {
			summ = summ + as.numeric(c[[l]][2])		
		}
		# Insert values into new predict table.
		for(k in 1:cols) {
			if(summ != 0) {
				table[i,k] = as.numeric(c[[k]][2])/summ
			} else {
				table[i,k] = 0
			}			
		}
	}	

 	return(table)
}

